<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 300px;
            border: 1px solid red;
            position: relative;
        }
        .box img {
            width: 100%;
            height: 100% ;
        }
        .box button{
           position: absolute;
           right: 10px;
           top: 10px;
           border: 1px solid black;
           width: 20px;
           height: 20px;
           text-align: center;
        }
    </style>
</head>
<body>
    <!-- 实现流氓广告的关闭
    显示一个流氓广告框，点击关闭后 4秒钟后继续显示出来  -->
    
    <div class="box">
        <button>X</button>
        <img src="./2.jpg" alt="">
    </div>

    <script>
        //获取元素
        var box = document.querySelector(".box");
        var btn = document.querySelector("button");
        // console.log(box);
        // console.log(btn)

        var flag = true;
        btn.onclick=function(){     //点击事件
            if (flag ==flag){
                box.style.display =`none`
            }
        }
        //4s后显示  
        setInterval(function(){
            box.style.display=`block`
        },4000);
    </script>
</body>
</html>